# -*- coding: utf-8 -*-
# @desc: 
# @file: days_buy_selector.py
# @author: Lin Jackey Lyu (me@linlyu.com)
# @date: 2019/3/1 17:38
from collections import defaultdict
import datetime
from .base_selector import AbstractSelector


class DaysBuySelector(AbstractSelector):

    def __init__(self) -> None:
        super().__init__()
        self.pool = defaultdict(lambda : [])
        for line in open("data/days_buy.csv"):
            trade_date, stock = line.split(',')
            trade_date = trade_date.strip()
            stock = stock.strip()
            self.pool[trade_date].append(stock)

    def select(self, day) -> list:
        day = day.strftime("%Y%m%d")
        stocks = self.pool.get(day)
        return stocks if stocks else []
